package com.wt.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wt.admin.entity.WqunArticleTag;
import com.wt.admin.entity.WqunArticleTagType;
import com.wt.admin.entity.WqunSysMenu;
import com.wt.admin.mapper.WqunArticleTagTypeMapper;
import com.wt.admin.service.WqunArticleTagTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wt.commonutils.R;
import com.wt.servicebase.exceptionhandler.exceptionhandler.WQUNException;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 标签类型表 服务实现类
 * </p>
 *
 * @author wt
 * @since 2023-10-13
 */
@Service
public class WqunArticleTagTypeServiceImpl extends ServiceImpl<WqunArticleTagTypeMapper, WqunArticleTagType> implements WqunArticleTagTypeService {

    @Override
    public R findAllArticleTagType(int pageSize, int currentPage, String selectFind, String selectFindValue) {
        IPage<WqunArticleTagType> resultPage = new Page<>(currentPage,pageSize);
        QueryWrapper<WqunArticleTagType> queryWrapper = new QueryWrapper<>();
        if(!Objects.equals(selectFind, "NULL") && !Objects.equals(selectFindValue, "NULL")){
            queryWrapper.like(true,selectFind,selectFindValue);
        }
//        queryWrapper.orderByDesc("id");
        queryWrapper.eq("is_delete","0");
        IPage<WqunArticleTagType> iPage = baseMapper.selectPage(resultPage, queryWrapper);
        List<WqunArticleTagType> findAllArticleTagType = iPage.getRecords();
        long total = iPage.getTotal();

        return R.ok().data("findAllArticleTagType",findAllArticleTagType).data("total",baseMapper.selectPage(resultPage, queryWrapper).getTotal());

    }
}
